<?php
//  ------------------------------------------------------------------------ //
//                          MYIFRAME FOR XOOPS 2                             //
//                  Copyright (c) 2005-2006 Instant Zero                     //
//                     <http://xoops.instant-zero.com/>                      //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //

include_once XOOPS_ROOT_PATH.'/modules/myiframe/include/functions.php';

function b_myiframe_iframe_show($options) {
    $block = array();
	$iframe_handler =& xoops_getmodulehandler('myiframe', 'myiframe');
	$frame = $iframe_handler->get($options[0]);
	if(is_object($frame)) {
		$block['longdesc'] = $frame->getVar('frame_description');
		$block['width'] = $frame->getVar('frame_width');
		$block['height'] = $frame->getVar('frame_height');
		$block['align'] = $tblalign[$frame->getVar('frame_align')-1];
		$block['frameborder'] = $frame->getVar('frame_frameborder');
		$block['marginwidth'] = $frame->getVar('frame_marginwidth');
		$block['marginheight'] = $frame->getVar('frame_marginheight');
		$block['scrolling'] = $tblscrolling[$frame->getVar('frame_scrolling')-1];
		if(xoops_trim($suplparam) != '') {
			$block['url'] = $frame->getVar('frame_url') . '?' . $suplparam;
		} else {
			$block['url'] = $frame->getVar('frame_url');
		}
	}
	return $block;
}

function b_myiframe_iframe_edit($options) {
	$iframe_handler =& xoops_getmodulehandler('myiframe', 'myiframe');
	$frarray = array();
	$critere = new Criteria('1', '1','=');
	$critere->setSort('frame_description');
	$frarray = $iframe_handler->getObjects($critere);

    $form = ""._MB_MYIFRAME_IFRAME."&nbsp;<select name='options[0]'>";
    foreach($frarray as $oneframe) {
    	$form .= "<option value='".$oneframe->getVar('frame_frameid')."'";
    	if ($options[0] == $oneframe->getVar('frame_frameid')) {
	        $form .= " selected='selected'";
	    }
	    $form .= '>'.$oneframe->getVar('frame_description').'</option>';
	}
    $form .= "</select>\n";
    return $form;
}


function b_myiframe_iframe_onthefly($options)
{
	$options = explode('|',$options);
	$block = & b_myiframe_iframe_show($options);

	$tpl = new XoopsTpl();
	$tpl->assign('block', $block);
	$tpl->display('db:myiframe_block_show.html');
}
?>